﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JY.Common.WcfHost.Configurations
{
    /// <summary>
    /// WcfHost配置节点
    /// </summary>
    public class WcfHostSection : ConfigurationSection
    {
        #region # 字段

        /// <summary>
        /// WcfHost配置节点
        /// </summary>
        private static readonly WcfHostSection _WcfHostSection;
        #endregion

        #region # 构造器

        /// <summary>
        /// 静态构造器
        /// </summary>
        static WcfHostSection()
        {
            _WcfHostSection = (WcfHostSection)ConfigurationManager.GetSection("jy.wcf");

            #region # 非空验证

            if (_WcfHostSection == null)
            {
                throw new ApplicationException("jy.wcf节点未配置，请检查配置文件！");
            }

            #endregion
        }
        #endregion

        #region # 访问器 —— static IocSection Section
        /// <summary>
        /// 访问器
        /// </summary>
        public static WcfHostSection Section
        {
            get { return _WcfHostSection; }
        }
        #endregion


        #region # 服务名称节点 —— TextElement ServiceName
        /// <summary>
        /// 服务名称节点
        /// </summary>
        [ConfigurationProperty("serviceName", IsRequired = false)]
        public TextElement ServiceName
        {
            get { return (TextElement)this["serviceName"]; }
            set { this["serviceName"] = value; }
        }
        #endregion

        #region # 服务显示名称节点 —— TextElement ServiceDisplayName
        /// <summary>
        /// 服务显示名称节点
        /// </summary>
        [ConfigurationProperty("serviceDisplayName", IsRequired = false)]
        public TextElement ServiceDisplayName
        {
            get { return (TextElement)this["serviceDisplayName"]; }
            set { this["serviceDisplayName"] = value; }
        }
        #endregion

        #region # 服务描述节点 —— TextElement ServiceDescription
        /// <summary>
        /// 服务描述节点
        /// </summary>
        [ConfigurationProperty("serviceDescription", IsRequired = false)]
        public TextElement ServiceDescription
        {
            get { return (TextElement)this["serviceDescription"]; }
            set { this["serviceDescription"] = value; }
        }
        #endregion

        #region # WCF服务实现类库名称节点 —— TextElement WcfImplementAssembly
        /// <summary>
        /// WCF服务实现类库名称节点
        /// </summary>
        [ConfigurationProperty("wcfImplementAssembly", IsRequired = false)]
        public TextElement WcfImplementAssembly
        {
            get { return (TextElement)this["wcfImplementAssembly"]; }
            set { this["wcfImplementAssembly"] = value; }
        }
        #endregion
    }
}
